package util
{
	import flash.utils.ByteArray;
	
	public class UtileFunc
	{
		public function UtileFunc()
		{
		}
		
		public static function spliteStr2Array(str:String):Array
		{
			var a:Array = new Array();
			var i:int = 0;
			while(i < str.length)
			{
				a.push(str.substr(i, 1));
				i++;
			}
			
			return a;
		}
		
		public static function mergeArray2Str(a:Array):String
		{
			var num:int = a.length;
			var retStr:String = '';
			for (var i:int=0; i<num;i++)
			{
				retStr += a[i];
			}
			
			return retStr;
		}
		
		public static function time2Date(time:Number):Date
		{
			var date:Date = new Date();
			date.setTime(time*1000);   //from php, need to multiply 1000
			
			return date;
		}
		
		public static function date2Time(date:Date):Number
		{
			return date.getTime() / 1000;   //to php, need to apart 1000
		}
		
        public static function clone(source:Object):*
		{
		    var myBA:ByteArray = new ByteArray();
		    myBA.writeObject(source);
		    myBA.position = 0;
		    return(myBA.readObject());
		}		

	}
}